package com.example.myapplication;

import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Fragment1 extends Fragment {
    RecyclerView recyclerView;
    List<Map<String, Object>> list1;
    Myadapter1  myadapter;
    Context fragmentContext;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.tab1, container, false);
        recyclerView = view.findViewById(R.id.recyclerView);

        int[] picture = {R.drawable.hd1, R.drawable.hd2, R.drawable.hd3, R.drawable.hd4, R.drawable.hd5, R.drawable.hd6, R.drawable.hd7, R.drawable.hd8};
        String text1 = new String();
        list1 = new ArrayList<>();
        for (int i = 0; i < picture.length; i++) {
            Map<String, Object> map = new HashMap<>();
            map.put("picture", picture[i]);
            map.put("text", text1);
            list1.add(map);
        }

        fragmentContext = getContext();
        myadapter = new Myadapter1(getContext(),list1);
        RecyclerView.LayoutManager manager = new LinearLayoutManager(fragmentContext);
        recyclerView.setLayoutManager(manager);
        recyclerView.setAdapter(myadapter);



        return view;
    }
}